package com.winit.psc.repository;

import com.winit.psc.model.PmsCategory;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PmsCategoryRepository extends CrudRepository<PmsCategory, Integer> {

    List<PmsCategory> findAll();

    @Query(value = "SELECT * from pms_category where CATEGORY_TYPE=?1 and PARENT_ID = ?2 and IS_ACTIVE='Y' and IS_DELETE = 'N'", nativeQuery = true)
    List<PmsCategory> findAllByTypeAndParent(String type, Integer parent);

}
